<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>滨海基金 -首页</title>
<link rel="shortcut icon" href="favicon.ico">
<link href="css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
<link href="css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<link href="css/style.min.css?v=4.0.0" rel="stylesheet">
<base target="_blank">
<link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">
<script src="js/common.js"></script>

<style type="text/css">
.div {
	float: left;
	width: 65%;
}
</style>
</head>

<body class="gray-bg">
	<div class="div">
		<div class="wrapper wrapper-content animated fadeInUp">
			<ul id="indexUl" class="notes" style="height: 100vh">

			</ul>
		</div>
	</div>
	<div class="float-e-margins"
		style="width: 35%; height: 50%; float: left; overflow: hidden;">
		<div class="ibox-title">
			<h5>今日行程  <a style="text-align: center;"onclick="location.href='trip.do?id=1?v=4.0'"><small>更多>></small></a></h5>
		</div>
		<div >
			<div style="height: 100vh;"  class="ibox-content timeline">
			<ul class="sortable-list connectList agile-list" id="tripList">
			 </ul>
			</div>
		</div>
	</div>
	<div class="float-e-margins"
		style="width: 35%; height: 50%; float: left; overflow: hidden;">
		<div class="ibox-title">
			<h5>合同返利提醒 <a style="text-align: center;"onclick="location.href='toContractRebateList.do?v=4.0'"><small>更多>></small></a></h5>
		</div>
		<div>
			<div style="height: 100vh;"  class="ibox-content timeline">
			 <ul class="sortable-list connectList agile-list" id="contractList">
			 </ul>
			</div>
		</div>
	</div>
</body>
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/plugins/toastr/toastr.min.js"></script>
<script src="./js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="js/bootstrap.min.js?v=3.3.5"></script>
<script src="js/content.min.js?v=1.0.0"></script>
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.5"></script>
<script src="js/content.min.js?v=1.0.0"></script>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$
								.ajax({
									type : "POST",
									url : "indexNoticeList.do",
									cache : false, //禁用缓存
									//data: param,  //传入组装的参数
									dataType : "json",
									success : function(result) {
										console.log(result)
										$
												.each(
														result.data,
														function(index, notice) {
															if (notice.noticeState == "1") {

																$("#indexUl")
																		.append(
																				"<li><div style=\"background-color: white;\"><small>"
																						+ toDate(notice.releaseDate)
																						+ "</small><h4 style=\"margin-left:60px;\">公告</h4><h5>"
																						+ notice.noticeTitle
																						+ "</h5><p style=\"height:100px;overflow: auto; cursor: pointer\" onclick=\"location.href='toNotice.do?id=1?v=4.0'\" >"
																						+ repaceStr(notice.noticeContent)
																						+ "</p>"
																						+ "<h5 style=\"position:absolute;right:30px;bottom:0px;\">"
																						+ notice.createPeople
																						+ "</h5>")
															} else { 
															$("#indexUl")
																	.append(
																			"<li><div style=\"background-color: white;\"><small>"
																					+ toDate(notice.releaseDate)
																					+ "</small><h4 style=\"margin-left:60px;\">通知</h4><h5>"
																					+ notice.noticeTitle
																					+ "</h5><p style=\"height:100px;overflow: auto;cursor: pointer\" onclick=\"location.href='toNotice.do?id=0?v=4.0'\">"
																					+  repaceStr(notice.noticeContent)
																					+ "</p>"
																					+ "<h5 style=\"position:absolute;right:30px;bottom:0px;\">"
																					+ notice.createPeople
																					+ "</h5>")
															}
														})
									},
									error : function() {
										sweetAlert("异常", "网络出现异常!", "error");
									}
								});
						$
								.ajax({
									type : "POST",
									url : "todayTrip.do",
									cache : false, //禁用缓存
									//data: param,  //传入组装的参数
									dataType : "json",
									success : function(result) {
										if (result.data.length > 0) {
											var i = 0;
											while(i<2){
											$.each(
															result.data,
															function(index,
																	trip) {
																var tripContent = trip.tripContent;
																if(tripContent.length>25){
																	tripContent = tripContent.substring(0,25) + "......";
																}
																
																$("#tripList")
																		.append(
																				/* "<div class=\"timeline-item\"><div class=\"row\"><div class=\"col-xs-3 date\"><i class=\"fa fa-file-text\"></i>"
																						+ toDate(trip.startDate)
																						+ "<br><small class=\"text-navy\">"
																						+ trip.relatedCustomers
																						+ "</small><br>"
																						+ "</div><div class=\"col-xs-7 content\"><p class=\"m-b-xs\"><strong>"
																						+ trip.tripType
																						+ "</strong></p><p>"
																						+ trip.tripTheme
																						+ "</p></div>" */
																				"<li class=\"success-element\">"
																				+ tripContent
																				+ "<div class=\"agile-detail\">"
																				+ "<i class=\"fa fa-clock-o\"></i>"
																				+ toYearDate(trip.startDate) 
																				+ "</div></li>"
																		)
																		
															})
															//控制计划的条数为两条
															if(result.data.length > 2){
																i++;
															}
															else{
																i = 3
															}
											}
										} else {
											$("#tripList").append(
													"今日暂无行程安排 ... ...")
										}
									},
									error : function() {
										sweetAlert("异常", "网络出现异常!", "error");
									}
								});
						//获取数据数目
						var param = {};
						param.limit = 2;
						param.page = 1
						//查询返利的合同的标记
						param.isRebate = 1;
						$
								.ajax({
									type : "POST",
									url : "contract.do",
									cache : false, //禁用缓存
									data: param,  //传入组装的参数
									dataType : "json",
									success : function(result) {
										var i = 0;
										if (result.data.length > 0) {
											$.each(
													result.data,
													function(index,trip) {
															var contract = result.data[i];
															var contractNum = contract.contractNum;
															var contractName = contract.contractName;
															if(contractName.length>25){
																contractName = contractName.substring(0,20) + "......";
															}
															var investmentHorizon;
															if(contract.investmentHorizon = 1){
																investmentHorizon = "一个月";
															}
															else if(contract.investmentHorizon = 2){
																investmentHorizon = "三个月";
															}
															else if(contract.investmentHorizon = 3){
																investmentHorizon = "一年";
															}
															else{
																investmentHorizon = "";
															}
															$("#contractList").append(
																	"<li class=\"success-element\">"
																	+ "合同名称：" + contractName
																	+ "<div class=\"agile-detail\">"
																	+ " <span class=\"pull-right \">"
																	+ '返利期限： ' +investmentHorizon
																	+ "</span>"
																	+ "<i class=\"fa fa-clock-o\"></i>"
																	+ toYearDate(contract.startDate)
																	+ "--"
																	+ toYearDate(contract.endDate)
																	+ "</div></li>"
															)
													})
										} else {
											$("#planList").append(
													"暂无合同返利 ... ...")
										}
									},
									error : function() {
										sweetAlert("异常", "网络出现异常!", "error");
									}
								});
						function toDate(data) {
							var date = new Date(data);
							var y = date.getFullYear();
							var m = date.getMonth() + 1;
							var hour = date.getHours();
							var minute = date.getMinutes();
							m = m < 10 ? '0' + m : m;
							var d = date.getDate();
							d = d < 10 ? ('0' + d) : d;
							hour = hour < 10 ? '0' + hour : hour;
							minute = minute < 10 ? '0' + minute : minute;
							return m + '-' + d + " " + hour + ":" + minute;
						}
						//工作计划日期格式化
						function toYearDate(data) {
							var date = new Date(data);
							var y = date.getFullYear();
							var m = date.getMonth() + 1;
							m = m < 10 ? '0' + m : m;
							var d = date.getDate();
							d = d < 10 ? ('0' + d) : d;
							return y + '-' + m + '-' + d;
						}
						/* 关于新通知 */
						toastr.options = {
							"closeButton" : true,
							"debug" : false,
							"progressBar" : false,
							"positionClass" : "toast-top-right",
							"onclick" : function(){
								//parent.window.triggerA("#birthdayRemind");
							},
							"showDuration" : "400",
							"hideDuration" : "5000",
							"timeOut" : "999999999",
							"extendedTimeOut" : "999999999",
							"showEasing" : "swing",
							"hideEasing" : "linear",
							"showMethod" : "fadeIn",
							"hideMethod" : "fadeOut"
						};
						//获取客户生日信息
						$.ajax({
							type : "POST",
							url : "customerBirthdayCount.do",
							cache : false, //禁用缓存
							//data: param,  //传入组装的参数
							dataType : "json",
							success : function(result) {
								if (result.count > 0) {
									toastr.info("<a onclick='parent.window.triggerA(\"#birthdayRemind\")'>您有" + result.count
											+ "个客户近期即将过生日！", "客户生日提醒</a>");
								}
							},
							error : function() {
							}
						});
						var param = {};
						param.contractEndDate = 1;
						param.limit = 1;//
						param.page = 10;//
						//获取客户生日信息
						$.ajax({
							type : "POST",
							url : "contract.do",
							cache : false, //禁用缓存
							data: param,  //传入组装的参数
							dataType : "json",
							success : function(result) {
								console.log(result.total)
								if (result.total > 0) {
									toastr.info("<a onclick='parent.window.triggerA(\"#contractExpiring\")'>您有" + result.total
											+ "个合同即将到期！", "合同到期提醒</a>");
								}
							},
							error : function() {
							}
						});
					});
</script>
<script type="text/javascript">
	function repaceStr(str){
		str=str.replace(/<img[^>]*>/g,'')
   		String.prototype.stripHTML = function() {
        var reTag = /<(?:.|\s)*?>/g;
        return this.replace(reTag,"");
      	}
   		var returnStr = str.stripHTML();
   		if(returnStr.length > 50){
   			returnStr = returnStr.substring(0,50) +"......";
   		}
     	return returnStr;
	}
    </script>
</html>